package com.beiding.editanalyzeframe;

/**
 * 分析行
 *
 * @author 丁常磊
 * @date 2021/12/1 9:19
 */

public class AnalyseLine {

    /**
     * 行状态
     */
    LineStatus status;

    /**
     * 来源行
     */
    Line sourceLine;

    /**
     * 目标行
     */
    Line targetLine;

    public boolean isEdit() {
        return getStatus() == LineStatus.EDIT;
    }

    public boolean isAdd() {
        return getStatus() == LineStatus.ADD;
    }

    public boolean isSame() {
        return getStatus() == LineStatus.SAME;
    }

    public boolean isDelete() {
        return getStatus() == LineStatus.DELETE;
    }

    public Line getSourceLine() {
        return sourceLine;
    }

    public Line getTargetLine() {
        return targetLine;
    }

    public LineStatus getStatus() {
        return status;
    }

    @Override
    public String toString() {
        if (LineStatus.SAME.equals(status)||LineStatus.EDIT.equals(status)) {
            return status + " " + sourceLine + "\n     " + targetLine;
        }else if (LineStatus.DELETE.equals(status)) {
            return status + " " + sourceLine;
        }else if (LineStatus.ADD.equals(status)) {
            return status + " " + targetLine;
        }
        return "";
    }
}
